package org.example.travel_web.controller.admin;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.example.travel_web.dto.PageResult;
import org.example.travel_web.dto.comment.CommentDetail;
import org.example.travel_web.dto.comment.CommentPageResp;
import org.example.travel_web.dto.comment.PageReq;
import org.example.travel_web.service.CommentsService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/comment")
@Tag(name = "评论管理")
public class CommentController {

    @Resource
    private CommentsService commentsService;

    @GetMapping
    @Operation(summary = "评论分页")
    public PageResult<CommentPageResp> pageResult(@Valid PageReq pageReq) {
        return commentsService.pageResult(pageReq);
    }

    @GetMapping("/{id}")
    @Operation(summary = "获取评论详情")
    @Parameter(name = "id", description = "评论 ID", required = true, in = ParameterIn.PATH)
    public CommentDetail getCommentDetail(@PathVariable Integer id) {
        return commentsService.getCommentDetail(id);
    }

    @PutMapping("/status/{id}")
    @Operation(summary = "修改评论状态")
    public void updateCommentStatus(@PathVariable Integer id) {
        commentsService.updateCommentStatus(id);
    }

    @DeleteMapping
    @Operation(summary = "删除评论")
    @Parameter(name = "ids", description = "评论 ID 数组", required = true, in = ParameterIn.QUERY)
    public void deleteComment(@RequestParam Integer[] ids) {
        commentsService.deleteComment(ids);
    }

}
